/* GLCamera.h
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <utils/glvector.h>

#ifndef GLCAMERA_H_
#define GLCAMERA_H_

class GLScene;

class GLCamera
{
protected:
	vector3d position;
	vector3d target;
	vector3d look;
	vector3d vertical;

	double theta; // angle between x and the look vector (left/right)
	double phi; // angle between y and the look vector (up/down)

public:
	GLCamera();

	const vector3d& getPosition() const { return position; }
	const vector3d& getLook() const { return look; }
	const vector3d& getTarget() const { return target; }
	const vector3d& getVertical() const { return vertical; }
	double getTheta() const { return theta; }
	double getPhi() const { return phi; }

	void setPosition(double x, double y, double z) { position = vector3d(x, y, z); }
	void setPosition(const vector3d v) { position = v; }
	void setLook(double x, double y, double z) { look = vector3d(x, y, z); }
	void setLook(const vector3d v) { look = v; }
	void setVertical(double x, double y, double z) { vertical = vector3d(x, y, z); }
	void setVertical(const vector3d v) { vertical = v; }
	void setTheta(double angle) { theta = angle; updateLook(); }
	void setPhi(double angle) { phi = angle; updateLook(); }

private:
	void updateCamera();
	void updateLook();
	friend class GLScene;
};

#endif /* GLCAMERA_H_ */
